<template>
    <div class="form-block-inner">
        <Form ref="formItem" :rules="ruleValidate" :model="formItem" label-position="top">
            <div class="title-style">2021年度项目类资金</div>
            <Row :gutter="16">
                <Col span="24">
                    <Row :gutter="16">
                        <Col span="8">
                            <FormItem prop="project_name" label="项目名称:">
                                <Input v-model="formItem.project_name" placeholder="请输入项目名称"/>
                            </FormItem>
                        </Col>
                        <Col span="8">
                            <FormItem prop="project_type" label="项目类型：">
                                <RadioGroup v-model="formItem.project_type">
                                    <Radio label="1">补贴类</Radio>
                                    <Radio label="2">建设类</Radio>
                                    <Radio label="3">购买商品和服务类</Radio>
                                    <Radio label="99">其他</Radio>
                                </RadioGroup>
                            </FormItem>
                        </Col>
                        <template v-if="formItem.project_type == '2'">
                            <Col span="8">
                                <FormItem prop="project_type_build" label="建设类项目:">
                                    <RadioGroup v-model="formItem.project_type_build">
                                        <Radio label="0">新建项目</Radio>
                                        <Radio label="1">延续项目</Radio>
                                    </RadioGroup>
                                </FormItem>
                            </Col>
                        </template>
                        <template v-if="formItem.project_type == '99'">
                            <div class="type-style">
                                <Col span="8">
                                    <FormItem prop="project_type_other" label="其他类型：">
                                        <Input v-model="formItem.project_type_other" placeholder="请输入其他类型"/>
                                    </FormItem>
                                </Col>
                            </div>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                    <Row :gutter="16">
                        <Col span="8">
                            <FormItem prop="budget" label="预算额度:">
                                <Input v-model="formItem.budget" type="number" placeholder="请输入预算额度">
                                    <span slot="append">万元</span>
                                </Input>
                            </FormItem>
                        </Col>
                        <Col span="8">
                            <FormItem prop="capital_source" label="资金来源:">
                                <Input v-model="formItem.capital_source" placeholder="请输入资金来源"></Input>
                                <!--<RadioGroup v-model="formItem.capital_source">
                                    <Radio label="1">国家</Radio>
                                    <Radio label="2">市本级财政资金</Radio>
                                    <Radio label="3">区县</Radio>
                                    <Radio label="99">其他</Radio>
                                </RadioGroup>-->
                            </FormItem>
                        </Col>
                        <Col span="8">
                            <FormItem prop="target_no" label="指标文号:">
                              <Input v-model="formItem.target_no" placeholder="请输入资金来源"></Input>
                            </FormItem>
                        </Col>
                        <template v-if="formItem.capital_source == '99'">
                            <Col span="8" style="margin-left: -1%">
                                <FormItem prop="capital_source_other" label="其他来源：">
                                    <Input v-model="formItem.capital_source_other" placeholder="请输入其他来源"/>
                                </FormItem>
                            </Col>
                        </template>
                        <Col span="24" >
                            <FormItem prop="project_cycle" label="项目周期：" >
                                <Input style="width: 32.5%" v-model="formItem.project_cycle" placeholder="请输入项目周期"/>
                            </FormItem>
                        </Col>
                        <template v-if="formItem.project_type == '1'">
                            <Col span="8">
                                <FormItem prop="issue_cycle" label="发放周期:">
                                    <RadioGroup v-model="formItem.issue_cycle">
                                        <!--<Radio label="1">一次性</Radio>-->
                                        <Radio label="2">周发放</Radio>
                                        <Radio label="3">月发放</Radio>
                                        <Radio label="4">季度发放</Radio>
                                        <Radio label="5">年度发放</Radio>
                                        <Radio label="99">其他</Radio>
                                    </RadioGroup>
                                </FormItem>
                            </Col>
                            <template v-if="formItem.issue_cycle == '99'">
                                <div class="type-style-four">
                                    <Col span="8">
                                        <FormItem prop="issue_cycle_other" label="其他发放周期：">
                                            <Input v-model="formItem.issue_cycle_other" placeholder="请输入其他发放周期"/>
                                        </FormItem>
                                    </Col>
                                </div>
                            </template>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                    <Row :gutter="16">
                        <template v-if="formItem.project_type != '1'">
                            <Col span="8">
                                <FormItem prop="settle_cycle" label="结算周期:">
                                    <RadioGroup v-model="formItem.settle_cycle">
                                        <!-- <Radio label="1">一次性</Radio>-->
                                        <Radio label="2">周结算</Radio>
                                        <Radio label="3">月结算</Radio>
                                        <Radio label="4">季度结算</Radio>
                                        <Radio label="5">年度结算</Radio>
                                        <Radio label="99">其他</Radio>
                                    </RadioGroup>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <template v-if="formItem.settle_cycle == '99'">
                                    <FormItem prop="settle_cycle_other" label="其他结算周期：">
                                        <Input v-model="formItem.settle_cycle_other" placeholder="请输入其他结算周期"/>
                                    </FormItem>
                                </template>
                            </Col>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                    <Row :gutter="16">
                        <template v-if="formItem.project_type == '1'">
                            <Col span="8">
                                <FormItem prop="subsidy_object" label="补贴对象:">
                                    <CheckboxGroup v-model="formItem.subsidy_object" @on-change="subobj">
                                        <Checkbox label="1">个人</Checkbox>
                                        <Checkbox label="2">企业</Checkbox>
                                        <Checkbox label="3">社会机构</Checkbox>
                                        <Checkbox label="99">其他</Checkbox>
                                    </CheckboxGroup>
                                </FormItem>
                            </Col>
                            <Col span="8" v-if="showSubobj" style="margin-left: -12%">
                                <FormItem prop="subsidy_object_other" label="其他补贴对象：">
                                    <Input v-model="formItem.subsidy_object_other" placeholder="请输入其他补贴对象"/>
                                </FormItem>
                            </Col>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                    <Row :gutter="16">
                        <template v-if="formItem.project_type != '1'&& formItem.project_type == '2'">
                            <Col span="8">
                                <FormItem prop="settle_object" label="结算对象:">
                                    <CheckboxGroup v-model="formItem.settle_object" @on-change="setto">
                                        <Checkbox label="2">企业</Checkbox>
                                        <Checkbox label="3">社会机构</Checkbox>
                                        <Checkbox label="99">其他</Checkbox>
                                    </CheckboxGroup>
                                </FormItem>
                            </Col>
                        </template>
                        <template v-if="formItem.project_type == '3'|| formItem.project_type == '99'">
                            <Col span="8">
                                <FormItem prop="settle_object" label="结算对象:">
                                    <CheckboxGroup v-model="formItem.settle_object" @on-change="sett">
                                        <Checkbox label="1">个人</Checkbox>
                                        <Checkbox label="2">企业</Checkbox>
                                        <Checkbox label="3">社会机构</Checkbox>
                                        <Checkbox label="99">其他</Checkbox>
                                    </CheckboxGroup>
                                </FormItem>
                            </Col>
                        </template>
                        <template v-if="formItem.project_type != '1'">
                            <div class="type-style-three">
                                <Col span="8" v-if="showSetto">
                                    <FormItem prop="settle_object_other" label="其他结算对象：">
                                        <Input v-model="formItem.settle_object_other" placeholder="请输入其他结算对象"/>
                                    </FormItem>
                                </Col>
                            </div>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                    <Row :gutter="16">
                        <template v-if="formItem.project_type == '1'">
                            <Col span="12">
                                <FormItem prop="subsidy_way" label="补贴方式:">
                                    <CheckboxGroup v-model="formItem.subsidy_way" @on-change="subway">
                                        <Checkbox label="1">资金</Checkbox>
                                        <Checkbox label="2">实物</Checkbox>
                                        <Checkbox label="3">票劵</Checkbox>
                                        <Checkbox label="4">代金券</Checkbox>
                                        <Checkbox label="99">其他</Checkbox>
                                    </CheckboxGroup>
                                </FormItem>
                            </Col>
                            <Col span="12" style="margin-left: -25%" v-if="showSubway">
                                <FormItem prop="subsidy_way_other" label="其他补贴方式：">
                                    <Input v-model="formItem.subsidy_way_other" style="width: 400px" placeholder="请输入其他补贴方式"/>
                                </FormItem>
                            </Col>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                    <Row :gutter="16">
                        <template v-if="formItem.project_type === '1'">
                            <Col span="24">
                                <FormItem label="补贴代发银行:" prop="subsidy_bank">
                                    <CheckboxGroup v-model="formItem.subsidy_bank" @on-change="selectOptionOne" placeholder="请选择开户银行">
                                        <Checkbox label="盛京银行"></Checkbox>
                                        <Checkbox label="中国工商银行"></Checkbox>
                                        <Checkbox label="中国建设银行"></Checkbox>
                                        <Checkbox label="中国农业银行"></Checkbox>
                                        <Checkbox label="中国银行"></Checkbox>
                                        <Checkbox label="中国交通银行"></Checkbox>
                                        <Checkbox label="中国邮政储蓄银行"></Checkbox>
                                        <Checkbox label="中信银行"></Checkbox>
                                        <Checkbox label="光大银行"></Checkbox>
                                        <Checkbox label="招商银行"></Checkbox>
                                        <Checkbox label="浦发银行"></Checkbox>
                                        <Checkbox label="民生银行"></Checkbox>
                                        <Checkbox label="华夏银行"></Checkbox>
                                        <Checkbox label="平安银行"></Checkbox>
                                        <Checkbox label="兴业银行"></Checkbox>
                                        <Checkbox label="广发银行"></Checkbox>
                                        <Checkbox label="渤海银行"></Checkbox>
                                        <Checkbox label="浙商银行"></Checkbox>
                                        <Checkbox label="恒丰银行"></Checkbox>
                                        <Checkbox label="其他"></Checkbox>
                                        <div v-if="showCheckOne" class="other-style">
                                            <Input v-model="formItem.other_subsidy_bank"  placeholder="填报开户银行"/>
                                        </div>
                                    </CheckboxGroup>
                                </FormItem>
                            </Col>
                            <Col span="24">
                                <FormItem label="现金发放:" prop="subsidy_cash">
                                    <CheckboxGroup v-model="formItem.subsidy_cash">
                                        <Checkbox label="1">现金发放</Checkbox>
                                    </CheckboxGroup>
                                </FormItem>
                            </Col>
                            <template>
                                <Col span="24">
                                    <FormItem label="补贴支付账户：" v-model="formItem.pay_account" :required="true">
                                        <Divider orientation="left" size="small">零余额账户</Divider>
                                    </FormItem>
                                </Col>
                                <Col span="24">
                                    <FormItem prop="pay_account_bank" label="支付银行：">
                                        <RadioGroup v-model="formItem.pay_account_bank">
                                            <Radio label="盛京银行"></Radio>
                                            <Radio label="中国工商银行"></Radio>
                                            <Radio label="中国建设银行"></Radio>
                                            <Radio label="中国农业银行"></Radio>
                                            <Radio label="中国银行"></Radio>
                                            <Radio label="中国交通银行"></Radio>
                                            <Radio label="中国邮政储蓄银行"></Radio>
                                            <Radio label="中信银行"></Radio>
                                            <Radio label="光大银行"></Radio>
                                            <Radio label="招商银行"></Radio>
                                            <Radio label="浦发银行"></Radio>
                                            <Radio label="民生银行"></Radio>
                                            <Radio label="华夏银行"></Radio>
                                            <Radio label="平安银行"></Radio>
                                            <Radio label="兴业银行"></Radio>
                                            <Radio label="广发银行"></Radio>
                                            <Radio label="渤海银行"></Radio>
                                            <Radio label="浙商银行"></Radio>
                                            <Radio label="恒丰银行"></Radio>
                                            <Radio label="其他"></Radio>
                                            <div v-if="formItem.pay_account_bank == '其他'" class="other-style">
                                                <Input v-model="formItem.other_pay_account_bank"  placeholder="请输入其它支付银行"/>
                                            </div>
                                        </RadioGroup>
                                    </FormItem>
                                </Col>
                                <template>
                                    <Col span="24">
                                        <Divider orientation="left" size="small">实体账户</Divider>
                                    </Col>
                                    <Col span="24">
                                        <FormItem prop="pay_account_banks" label="支付银行：">
                                            <CheckboxGroup v-model="formItem.pay_account_banks" @on-change="selectOptionTwo" placeholder="请选择支付银行">
                                                <Checkbox label="盛京银行"></Checkbox>
                                                <Checkbox label="中国工商银行"></Checkbox>
                                                <Checkbox label="中国建设银行"></Checkbox>
                                                <Checkbox label="中国农业银行"></Checkbox>
                                                <Checkbox label="中国银行"></Checkbox>
                                                <Checkbox label="中国交通银行"></Checkbox>
                                                <Checkbox label="中国邮政储蓄银行"></Checkbox>
                                                <Checkbox label="中信银行"></Checkbox>
                                                <Checkbox label="光大银行"></Checkbox>
                                                <Checkbox label="招商银行"></Checkbox>
                                                <Checkbox label="浦发银行"></Checkbox>
                                                <Checkbox label="民生银行"></Checkbox>
                                                <Checkbox label="华夏银行"></Checkbox>
                                                <Checkbox label="平安银行"></Checkbox>
                                                <Checkbox label="兴业银行"></Checkbox>
                                                <Checkbox label="广发银行"></Checkbox>
                                                <Checkbox label="渤海银行"></Checkbox>
                                                <Checkbox label="浙商银行"></Checkbox>
                                                <Checkbox label="恒丰银行"></Checkbox>
                                                <Checkbox label="其他"></Checkbox>
                                                <div v-if="showCheck" class="other-style">
                                                    <Input v-model="formItem.other_pay_account_banks"  placeholder="请输入其支付银行"/>
                                                </div>
                                            </CheckboxGroup>
                                        </FormItem>
                                    </Col>
                                </template>
                            </template>
                            <Col span="24">
                                <Divider orientation="left" size="small">市财政直接拨付</Divider>
                            </Col>
                            <Col span="24">
                                <FormItem  prop="pay_account_direct">
                                    <CheckboxGroup v-model="formItem.pay_account_direct">
                                        <Checkbox label="1">市财政直接拨付</Checkbox>
                                    </CheckboxGroup>
                                </FormItem>
                            </Col>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                    <Row :gutter="16">
                        <template v-if="formItem.project_type !== '1'">
                            <Col span="24">
                                <FormItem  label="结算账户：" v-model="formItem.pay_account" :required="true">
                                    <Divider orientation="left" size="small">零余额账户</Divider>
                                </FormItem>
                            </Col>
                            <template>
                                <Col span="24">
                                    <FormItem prop="settle_account_bank" label="结算银行：">
                                        <RadioGroup v-model="formItem.settle_account_bank">
                                            <Radio label="盛京银行"></Radio>
                                            <Radio label="中国工商银行"></Radio>
                                            <Radio label="中国建设银行"></Radio>
                                            <Radio label="中国农业银行"></Radio>
                                            <Radio label="中国银行"></Radio>
                                            <Radio label="中国交通银行"></Radio>
                                            <Radio label="中国邮政储蓄银行"></Radio>
                                            <Radio label="中信银行"></Radio>
                                            <Radio label="光大银行"></Radio>
                                            <Radio label="招商银行"></Radio>
                                            <Radio label="浦发银行"></Radio>
                                            <Radio label="民生银行"></Radio>
                                            <Radio label="华夏银行"></Radio>
                                            <Radio label="平安银行"></Radio>
                                            <Radio label="兴业银行"></Radio>
                                            <Radio label="广发银行"></Radio>
                                            <Radio label="渤海银行"></Radio>
                                            <Radio label="浙商银行"></Radio>
                                            <Radio label="恒丰银行"></Radio>
                                            <Radio label="其他"></Radio>
                                            <div v-if="formItem.settle_account_bank == '其他'" class="other-style">
                                                <Input v-model="formItem.other_settle_account_bank"  placeholder="请输入其它结算银行"/>
                                            </div>
                                        </RadioGroup>
                                    </FormItem>
                                </Col>
                            </template>
                            <template>
                                <Col span="24">
                                    <Divider orientation="left" size="small">实体账户</Divider>
                                </Col>
                                <Col span="24">
                                    <FormItem label="结算银行：" prop="settle_account_banks">
                                        <CheckboxGroup v-model="formItem.settle_account_banks" @on-change="selectOption"
                                                       placeholder="请选择结算银行">
                                            <Checkbox label="盛京银行"></Checkbox>
                                            <Checkbox label="中国工商银行"></Checkbox>
                                            <Checkbox label="中国建设银行"></Checkbox>
                                            <Checkbox label="中国农业银行"></Checkbox>
                                            <Checkbox label="中国银行"></Checkbox>
                                            <Checkbox label="中国交通银行"></Checkbox>
                                            <Checkbox label="中国邮政储蓄银行"></Checkbox>
                                            <Checkbox label="中信银行"></Checkbox>
                                            <Checkbox label="光大银行"></Checkbox>
                                            <Checkbox label="招商银行"></Checkbox>
                                            <Checkbox label="浦发银行"></Checkbox>
                                            <Checkbox label="民生银行"></Checkbox>
                                            <Checkbox label="华夏银行"></Checkbox>
                                            <Checkbox label="平安银行"></Checkbox>
                                            <Checkbox label="兴业银行"></Checkbox>
                                            <Checkbox label="广发银行"></Checkbox>
                                            <Checkbox label="渤海银行"></Checkbox>
                                            <Checkbox label="浙商银行"></Checkbox>
                                            <Checkbox label="恒丰银行"></Checkbox>
                                            <Checkbox value="其他" label="其他"></Checkbox>
                                            <div v-if="showCheckThree" class="other-style">
                                                <Input v-model="formItem.other_settle_account_banks"  placeholder="请输入其结算银行"/>
                                            </div>
                                        </CheckboxGroup>
                                    </FormItem>
                                </Col>
                                <Col span="24">
                                    <Divider orientation="left" size="small">市财政直接拨付</Divider>
                                </Col>
                                <Col span="24">
                                    <FormItem  prop="settle_account_direct">
                                        <CheckboxGroup v-model="formItem.settle_account_direct">
                                            <Checkbox label="1">市财政直接拨付</Checkbox>
                                        </CheckboxGroup>
                                    </FormItem>
                                </Col>
                            </template>
                        </template>
                    </Row>
                </Col>
                <Col span="24">
                  <FormItem prop="project_instruction" label="项目说明：">
                     <Input v-model="formItem.project_instruction" type="textarea" :autosize="{minRows: 3,maxRows: 5}" placeholder="请输入项目说明"></Input>
                  </FormItem>
                </Col>
            </Row>
            <Divider/>
            <div class="button-group">
                <Button type="primary" @click="saveBtnAction" :loading="btnLoading">保存数据</Button>
            </div>
        </Form>
    </div>
</template>

<script>
import {
  insert,
  selectById,
  projectUpdate
} from '@/api/setting/capital'
export default {
  data () {
    // const validateSettleAccountBanks = (rule, value, callback) => {
    //   if (this.formItem.settle_account_banks.length === 0) {
    //     callback(new Error('结算银行不能为空'))
    //   } else {
    //     callback()
    //   }
    // }
    return {
      showSubobj: false,
      showSubway: false,
      showSetto: false,
      showCheckOne: false,
      showCheck: false,
      showCheckThree: false,
      ruleValidate: {
        other_settle_account_bank: [
          { required: true, message: '其他结算银行', trigger: 'blur' }
        ],
        other_settle_account_banks: [
          { required: true, message: '请输入其结算银行', trigger: 'blur' }
        ],
        other_pay_account_banks: [{
          required: true, message: '请输入其支付银行', trigger: 'blur'
        }],
        other_pay_account_bank: [{
          required: true, message: '请输入其支付银行', trigger: 'blur'
        }],
        other_subsidy_bank: [
          { required: true, message: '请输入其结算银行', trigger: 'blur' }
        ],
        project_name: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' }
        ],
        project_type: [
          { required: true, message: '补贴类型不能为空', trigger: 'change' }
        ],
        project_type_build: [
          { required: true, message: '建设类项目不能为空', trigger: 'change' }
        ],
        project_type_other: [
          { required: true, message: '其他项目类型不能为空', trigger: 'blur' }
        ],
        budget: [
          { required: true, message: '请填写正确金额', trigger: 'blur' }
        ],
        capital_source: [
          { required: true, message: '资金来源不能为空', trigger: 'change' }
        ],
        capital_source_other: [
          { required: true, message: '其他来源不能为空', trigger: 'blur' }
        ],
        project_cycle: [
          { required: true, message: '项目周期不能为空', trigger: 'blur' }
        ],
        issue_cycle: [
          { required: true, message: '发放周期不能为空', trigger: 'change' }
        ],
        issue_cycle_other: [
          { required: true, message: '其他发放周期不能为空', trigger: 'blur' }
        ],
        settle_cycle: [
          { required: true, message: '结算周期不能为空', trigger: 'change' }
        ],
        settle_cycle_other: [
          { required: true, message: '其他结算周期不能为空', trigger: 'blur' }
        ],
        subsidy_object: [
          { required: true, type: 'array', min: 1, message: '补贴对象不能为空', trigger: 'change' }
        ],
        subsidy_object_other: [
          { required: true, message: '其他补贴对象不能为空', trigger: 'blur' }
        ],
        settle_object: [
          { required: true, type: 'array', min: 1, message: '结算对象不能为空', trigger: 'change' }
        ],
        settle_object_other: [
          { required: true, message: '其他结算对象不能为空', trigger: 'blur' }
        ],
        subsidy_way: [
          { required: true, type: 'array', min: 1, message: '补贴方式不能为空', trigger: 'change' }
        ],
        subsidy_way_other: [
          { required: true, message: '其他补贴方式不能为空', trigger: 'blur' }
        ]
        // subsidy_bank: [
        //   { required: true, type: 'array', min: 1, message: '补贴代发银行不能为空', trigger: 'change' }
        // ]
        // pay_account: [
        //   { required: true, message: '支付账户不能为空', trigger: 'change' }
        // ],
        // pay_account_bank: [
        //   { required: true, message: '支付银行不能为空', trigger: 'change' }
        // ],
        // pay_account_banks: [
        //   { required: true, type: 'array', min: 1, message: '支付银行不能为空', trigger: 'change' }
        // ],
        // settle_account: [
        //   { required: true, message: '结算账户不能为空', trigger: 'change' }
        // ],
        // settle_account_bank: [
        //   { required: true, message: '结算银行不能为空', trigger: 'change' }
        // ],
        // settle_account_banks: [
        //   { required: true, type: 'array', min: 1, message: '结算银行不能为空', trigger: 'change' }
        // ]
      },
      formItem: {},
      btnLoading: false,
      projectSource: [
        {
          value: '1',
          label: '国家'
        },
        {
          value: '2',
          label: '市本级财政资金'
        },
        {
          value: '3',
          label: '区县'
        },
        {
          value: '99',
          label: '其他'
        }
      ],
      payBank: [
        {
          value: '中国工商银行',
          label: '中国工商银行'
        },
        {
          value: '中国建设银行',
          label: '中国建设银行'
        },
        {
          value: '中国农业银行',
          label: '中国农业银行'
        },
        {
          value: '中国银行',
          label: '中国银行'
        },
        {
          value: '中国交通银行',
          label: '中国交通银行'
        },
        {
          value: '中国邮政储蓄银行',
          label: '中国邮政储蓄银行'
        },
        {
          value: '中信银行',
          label: '中信银行'
        },
        {
          value: '光大银行',
          label: '光大银行'
        },
        {
          value: '招商银行',
          label: '招商银行'
        },
        {
          value: '浦发银行',
          label: '浦发银行'
        },
        {
          value: '民生银行',
          label: '民生银行'
        },
        {
          value: '华夏银行',
          label: '华夏银行'
        },
        {
          value: '平安银行',
          label: '平安银行'
        },
        {
          value: '兴业银行',
          label: '兴业银行'
        }, {
          value: '广发银行',
          label: '广发银行'
        }, {
          value: '渤海银行',
          label: '渤海银行'
        },
        {
          value: '浙商银行',
          label: '浙商银行'
        },
        {
          value: '恒丰银行',
          label: '恒丰银行'
        },
        {
          value: '盛京银行',
          label: '盛京银行'
        }
      ],
      settleBank: [
        {
          value: '中国工商银行',
          label: '中国工商银行'
        },
        {
          value: '中国建设银行',
          label: '中国建设银行'
        },
        {
          value: '中国农业银行',
          label: '中国农业银行'
        },
        {
          value: '中国银行',
          label: '中国银行'
        },
        {
          value: '中国交通银行',
          label: '中国交通银行'
        },
        {
          value: '中国邮政储蓄银行',
          label: '中国邮政储蓄银行'
        },
        {
          value: '中信银行',
          label: '中信银行'
        },
        {
          value: '光大银行',
          label: '光大银行'
        },
        {
          value: '招商银行',
          label: '招商银行'
        },
        {
          value: '浦发银行',
          label: '浦发银行'
        },
        {
          value: '民生银行',
          label: '民生银行'
        },
        {
          value: '华夏银行',
          label: '华夏银行'
        },
        {
          value: '平安银行',
          label: '平安银行'
        },
        {
          value: '兴业银行',
          label: '兴业银行'
        }, {
          value: '广发银行',
          label: '广发银行'
        }, {
          value: '渤海银行',
          label: '渤海银行'
        },
        {
          value: '浙商银行',
          label: '浙商银行'
        },
        {
          value: '恒丰银行',
          label: '恒丰银行'
        },
        {
          value: '盛京银行',
          label: '盛京银行'
        }
      ],
      optionType: 'add',
      projectID: '',
      rtobj: {}
    }
  },
  mounted () {
    if (this.$route.query.id) {
      this.projectID = this.$route.query.id
      this.optionType = 'edit'
      this.getInfoByID()
      // console.log(this.formItem.subsidy_bank, '6666')
      // let banks = this.formItem.subsidy_bank.toString()
      // if (banks.indexOf('其他') >= 0) {
      //   this.showCheck = true
      // } else {
      //   this.showCheck = false
      // }
      // let bank1 = this.formItem.pay_account_banks.toString()
      // if (bank1.indexOf('其他') >= 0) {
      //   this.showCheck = true
      // } else {
      //   this.showCheck = false
      // }
      // let bank2 = this.formItem.settle_account_banks.toString()
      // if (bank2.indexOf('其他') >= 0) {
      //   this.showCheck = true
      // } else {
      //   this.showCheck = false
      // }
      // this.selectOptionOne()
      // this.selectOptionTwo()
      // this.selectOption()
    } else {
      this.optionType = 'add'
    }
  },
  methods: {
    sett (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSetto = true
      } else {
        this.showSetto = false
        delete this.formItem.settle_object_other
      }
    },
    setto (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSetto = true
      } else {
        this.showSetto = false
        delete this.formItem.settle_object_other
      }
    },
    subway (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSubway = true
      } else {
        this.showSubway = false
        delete this.formItem.subsidy_way_other
      }
    },
    subobj (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSubobj = true
      } else {
        this.showSubobj = false
        delete this.formItem.subsidy_object_other
      }
    },
    selectOptionOne (val) {
      let banks = val.toString()
      if (banks.indexOf('其他') >= 0) {
        this.showCheckOne = true
      } else {
        this.showCheckOne = false
        delete this.formItem.other_subsidy_bank
      }
    },
    selectOptionTwo (val) {
      let banks = val.toString()
      if (banks.indexOf('其他') >= 0) {
        this.showCheck = true
      } else {
        this.showCheck = false
        delete this.formItem.other_pay_account_banks
      }
    },
    selectOption (val) {
      let banks = val.toString()
      if (banks.indexOf('其他') >= 0) {
        this.showCheckThree = true
      } else {
        this.showCheckThree = false
        delete this.formItem.other_settle_account_banks
      }
    },
    getInfoByID () {
      selectById({ id: this.projectID }).then(ret => {
        // console.log(this.projectID, '88888')
        let data = ret.data
        if (data.errcode === 0) {
          this.formItem = data.data
          // console.log(this.formItem.subsidy_bank.toString(), '6666')
          let banks = this.formItem.subsidy_bank.toString()
          if (banks.indexOf('其他') >= 0) {
            this.showCheckOne = true
          } else {
            this.showCheckOne = false
            delete this.formItem.other_subsidy_bank
          }
          let bank1 = this.formItem.pay_account_banks.toString()
          if (bank1.indexOf('其他') >= 0) {
            this.showCheck = true
          } else {
            this.showCheck = false
            delete this.formItem.other_pay_account_banks
          }
          let bank2 = this.formItem.settle_account_banks.toString()
          if (bank2.indexOf('其他') >= 0) {
            this.showCheckThree = true
          } else {
            this.showCheckThree = false
            delete this.formItem.other_settle_account_banks
          }
          let bank3 = this.formItem.settle_object.toString()
          if (bank3.indexOf('99') >= 0) {
            this.showSetto = true
          } else {
            this.showSetto = false
            delete this.formItem.settle_object_other
          }
          let bank4 = this.formItem.subsidy_way.toString()
          if (bank4.indexOf('99') >= 0) {
            this.showSubway = true
          } else {
            this.showSubway = false
            delete this.formItem.subsidy_way_other
          }
          let bank5 = this.formItem.subsidy_object.toString()
          if (bank5.indexOf('99') >= 0) {
            this.showSubobj = true
          } else {
            this.showSubobj = false
            delete this.formItem.subsidy_object_other
          }
        } else {
          this.error(data)
        }
      })
    },
    saveBtnAction () {
      if (this.formItem.project_type === '1') {
        if (this.$common.xeUtils.isEmpty(this.formItem.subsidy_bank) && this.$common.xeUtils.isEmpty(this.formItem.subsidy_cash)) {
          this.$Message.error('补贴代发银行、现金发放至少选一类')
        } else {
          if (this.$common.xeUtils.isEmpty(this.formItem.pay_account_bank) && this.$common.xeUtils.isEmpty(this.formItem.pay_account_banks) && this.$common.xeUtils.isEmpty(this.formItem.pay_account_direct)) {
            this.$Message.error('零余额、实体账户、市财政直接拨付至少选一类')
          } else {
            if (this.showCheckOne) {
              if (this.formItem.other_subsidy_bank === undefined || this.formItem.other_subsidy_bank === '') {
                this.$Message.error('开户银行不能为空')
                return
              }
            }
            if (this.showCheck) {
              if (this.formItem.other_pay_account_banks === undefined || this.formItem.other_pay_account_banks === '') {
                this.$Message.error('支付银行不能为空')
                return
              }
            }
            if (this.showCheckThree) {
              if (this.formItem.other_settle_account_banks === undefined || this.formItem.other_settle_account_banks === '') {
                this.$Message.error('结算银行不能为空')
                return
              }
            }
            if (this.formItem.pay_account_bank === '其他') {
              if (this.formItem.other_pay_account_bank === undefined || this.formItem.other_pay_account_bank === '') {
                this.$Message.error('支付银行不能为空')
                return
              }
            }
            if (this.formItem.settle_account_bank === '其他') {
              if (this.formItem.other_settle_account_bank === undefined || this.formItem.other_settle_account_bank === '') {
                this.$Message.error('结算银行不能为空')
                return
              }
            }
            let param = {}
            if (this.formItem.subsidy_bank === '' || this.formItem.subsidy_bank === undefined) {
              this.formItem.subsidy_bank = []
            }
            if (this.formItem.pay_account_banks === '' || this.formItem.pay_account_banks === undefined) {
              this.formItem.pay_account_banks = []
            }
            if (this.formItem.settle_account_banks === '' || this.formItem.settle_account_banks === undefined) {
              this.formItem.settle_account_banks = []
            }
            if (this.formItem.pay_account_direct === '' || this.formItem.pay_account_direct === undefined) {
              this.formItem.pay_account_direct = []
            }
            if (this.formItem.settle_account_direct === '' || this.formItem.settle_account_direct === undefined) {
              this.formItem.settle_account_direct = []
            }
            if (this.formItem.subsidy_object === '' || this.formItem.subsidy_object === undefined) {
              this.formItem.subsidy_object = []
            }
            if (this.formItem.settle_object === '' || this.formItem.settle_object === undefined) {
              this.formItem.settle_object = []
            }
            if (this.formItem.subsidy_way === '' || this.formItem.subsidy_way === undefined) {
              this.formItem.subsidy_way = []
            }
            if (this.formItem.subsidy_cash === '' || this.formItem.subsidy_cash === undefined) {
              this.formItem.subsidy_cash = []
            }
            if (this.optionType === 'add') {
              param = this.formItem
              // this.$delete(param, 'id')
            } else if (this.optionType === 'edit') {
              param = this.formItem
              if (this.$route.query.id) param.id = this.$route.query.id
            }
            /// ===1
            this.$refs['formItem'].validate((valid) => {
              if (valid) {
                if (this.optionType === 'add') {
                  this.addDataAction(param)
                } else if (this.optionType === 'edit') {
                  this.updateDataAction(param)
                }
              } else {
                this.$Message.error({
                  content: '操作失败,请核对添加信息后重试'
                })
              }
            })
          }
        }
      } else if (this.formItem.project_type !== '1') {
        if (this.$common.xeUtils.isEmpty(this.formItem.settle_account_bank) && this.$common.xeUtils.isEmpty(this.formItem.settle_account_banks) && this.$common.xeUtils.isEmpty(this.formItem.settle_account_direct)) {
          this.$Message.error('零余额、实体账户、市财政直接拨付至少选一类')
        } else {
          if (this.showCheckOne) {
            if (this.formItem.other_subsidy_bank === undefined || this.formItem.other_subsidy_bank === '') {
              this.$Message.error('开户银行不能为空')
              return
            }
          }
          if (this.showCheck) {
            if (this.formItem.other_pay_account_banks === undefined || this.formItem.other_pay_account_banks === '') {
              this.$Message.error('支付银行不能为空')
              return
            }
          }
          if (this.showCheckThree) {
            if (this.formItem.other_settle_account_banks === undefined || this.formItem.other_settle_account_banks === '') {
              this.$Message.error('结算银行不能为空')
              return
            }
          }
          if (this.formItem.pay_account_bank === '其他') {
            if (this.formItem.other_pay_account_bank === undefined || this.formItem.other_pay_account_bank === '') {
              this.$Message.error('支付银行不能为空')
              return
            }
          }
          if (this.formItem.settle_account_bank === '其他') {
            if (this.formItem.other_settle_account_bank === undefined || this.formItem.other_settle_account_bank === '') {
              this.$Message.error('结算银行不能为空')
              return
            }
          }
          let param = {}
          if (this.formItem.subsidy_bank === '' || this.formItem.subsidy_bank === undefined) {
            this.formItem.subsidy_bank = []
          }
          if (this.formItem.pay_account_banks === '' || this.formItem.pay_account_banks === undefined) {
            this.formItem.pay_account_banks = []
          }
          if (this.formItem.settle_account_banks === '' || this.formItem.settle_account_banks === undefined) {
            this.formItem.settle_account_banks = []
          }
          if (this.formItem.pay_account_direct === '' || this.formItem.pay_account_direct === undefined) {
            this.formItem.pay_account_direct = []
          }
          if (this.formItem.settle_account_direct === '' || this.formItem.settle_account_direct === undefined) {
            this.formItem.settle_account_direct = []
          }
          if (this.formItem.subsidy_object === '' || this.formItem.subsidy_object === undefined) {
            this.formItem.subsidy_object = []
          }
          if (this.formItem.settle_object === '' || this.formItem.settle_object === undefined) {
            this.formItem.settle_object = []
          }
          if (this.formItem.subsidy_way === '' || this.formItem.subsidy_way === undefined) {
            this.formItem.subsidy_way = []
          }
          if (this.formItem.subsidy_cash === '' || this.formItem.subsidy_cash === undefined) {
            this.formItem.subsidy_cash = []
          }
          if (this.optionType === 'add') {
            param = this.formItem
            // this.$delete(param, 'id')
          } else if (this.optionType === 'edit') {
            param = this.formItem
            if (this.$route.query.id) param.id = this.$route.query.id
          }
          this.$refs['formItem'].validate((valid) => {
            if (valid) {
              if (this.optionType === 'add') {
                this.addDataAction(param)
              } else if (this.optionType === 'edit') {
                this.updateDataAction(param)
              }
            } else {
              this.$Message.error({
                content: '操作失败,请核对添加信息后重试'
              })
            }
          })
        }
      }
    },
    updateDataAction (param) {
      // console.log(param, '修改')
      this.btnLoading = true
      projectUpdate(param).then(ret => {
        let data = ret.data
        if (data.errcode === 0) {
          this.btnLoading = false
          this.$Message.success('操作成功')
          // this.$router.push({ name: 'projectList' })
        } else {
          this.btnLoading = false
          this.error(data)
        }
      })
    },
    addDataAction (param) {
      // console.log(param, '添加')
      this.btnLoading = true
      insert(param).then(ret => {
        // console.log(ret, 'ret!!!add')
        this.rtobj = ret.data.data
        let data = ret.data
        if (data.errcode === 0) {
          this.btnLoading = false
          this.success()
          this.$Modal.confirm({
            title: '请前往完善行权事项信息',
            content: '<p>请前往完善行权事项信息</p>',
            loading: true,
            onOk: () => {
              setTimeout(() => {
                this.$Modal.remove()
                this.$router.push({
                  name: 'createList',
                  query: { id: this.rtobj.id, vtype: '2', project_name: this.rtobj.project_name }
                })
              }, 200)
            },
            onCancel: () => {
              this.$router.push({ name: 'projectList' })
            }
          })
        } else {
          this.btnLoading = false
          this.error(data)
          this.$router.push({ name: 'projectList' })
        }
      })
    },
    // confirmd () {
    //   this.$Modal.confirm({
    //     title: '请前往完善行权事项信息',
    //     content: '<p>请前往完善行权事项信息</p>',
    //     loading: true,
    //     onOk: () => {
    //       setTimeout(() => {
    //         this.$Modal.remove()
    //         this.$router.push({
    //           name: 'createList',
    //           query: { id: this.rtobj.id, vtype: '2', project_name: this.rtobj.project_name }
    //         })
    //       }, 200)
    //     }
    //   })
    // },
    success (val) {
      val = this.$common.xeUtils.isEmpty(val) ? '操作成功' : val
      this.$Message.success(val)
    },
    error (data) {
      this.$Message.error({
        content: '操作失败,\n' + data.errmsg
      })
    }
  }
}
</script>

<style scoped lang="less">
    .type-style /deep/ .ivu-col-span-8 {
        margin-left: -4%;
    }
    .type-style-one /deep/ .ivu-col-span-8 {
        margin-left: -2%;
    }
    .type-style-three /deep/ .ivu-col-span-8 {
        margin-left: -11%;
    }
    .type-style-four /deep/ .ivu-col-span-8 {
        margin-left: -3%;
    }
    .type-style-five /deep/ .ivu-col-span-8 {
        margin-left: -11%;
    }
    .input-one {
        margin-left: 10px;
    }

    .form-block-inner {
        height: 100%;
    }

    .tag-box {
        margin-bottom: 10px;
    }

    /deep/ .ivu-col-span-2 {
        margin-top: 23px;
    }

    .button-group {
        text-align: center;
    }

    .upload-icon {
        padding-left: 10px;
    }

    /deep/ .ivu-tooltip {
        /*width: 100%;*/
    }

    .excel-help {
        display: inline-block;
        margin-left: 10px;
        font-size: 16px;
        color: orange;
        cursor: pointer;
    }

    .other-style {
        display: inline-flex;
        margin-left: -2%;
    }
</style>
